import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 方法的使用
 * User: 阿宾
 * Date: 2024-05-03
 * Time: 19:39
 */
public class Test01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入机票原价：");
        int ticket = scanner.nextInt();
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        System.out.println("请选择头等舱或经济舱：0表示头等舱，1表示经济舱");
        int seat = scanner.nextInt();
        if(month > 12 || month <1){
            System.out.println("键盘录入的月份不合法");
        }else {
            if(month >= 5 && month <= 10){
                //月份为旺季
                if(seat == 0){
                    ticket *= 0.9;
                }else if(seat == 1){
                    ticket *= 0.85;
                }else {
                    System.out.println("舱位输入有误");
                }
            }else {
                //月份为淡季
                if(seat == 0){
                    ticket *= 0.7;
                }else if(seat == 1){
                    ticket *= 0.65;
                }else {
                    System.out.println("舱位输入有误");
                }
            }
        }
        System.out.println(ticket);


    }
    public static void main9(String[] args) {
        int[] arr = {10, 20};
        System.out.println(arr);//打印数组的地址值  0x776ec8df
        swap(arr);
        System.out.println("arr[0] = " + arr[0] + " arr[1] = " + arr[1]);
    }
    public static void swap(int[] arr) {
        int tmp = arr[0];
        arr[0] = arr[1];
        arr[1] = tmp;
    }
    public static void main8(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9};
        int[] ret = copyArr(arr,3,6);
        for (int i = 0; i < ret.length; i++) {
            System.out.print(ret[i] + " ");
        }
    }
    //拷贝数据
    public static int[] copyArr(int[] arr,int from,int to){
        int len = to - from;
        int[] copyarr = new int[len];
        int k = 0;
        for (int i = from; i < to; i++,k++) {
            copyarr[k] = arr[i];
        }
        return copyarr;
    }
    public static void main7(String[] args) {
        int[] arr = {11,22,56,78,10};
        int key = 0;
        boolean ret = isContain(arr,key);
        System.out.println(ret);
    }
    //判断值在数组中是否存在
    public static boolean isContain(int[] arr,int key){
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == key){
                return true;
            }
        }
        return false;
    }
    public static void main6(String[] args) {
        int[] arr = {11,22,56,78,10};
        int ret = maxArr(arr);
        System.out.println(ret);
    }
    //求数组最大值
    public static int maxArr(int[] arr){
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(max < arr[i]){
                max = arr[i];
            }
        }
        return  max;
    }
    public static void main5(String[] args) {
        int[] arr = {12,34,55,77,99};
        printArr(arr);
    }
    //方法定义
    public static void printArr(int[] arr){
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if(i == arr.length-1){
                System.out.print(arr[i] + "]");
            }else {
                System.out.print(arr[i] + ",");
            }
        }
        System.out.println();
    }
    public static void main1(String[] args) {
        Scanner scan = new Scanner((System.in));
        int count = 3;
        while(count != 0){
            System.out.println("请输入密码，你还有"+count+"次机会");
            String password = scan.nextLine();
            if(password.equals("123456")){
                System.out.println("登录成功");
                break;
            }else{
                count--;
                System.out.println("登录失败");
            }
        }
    }

    //判断闰年方法
    public static  boolean isLeapYear(int year){
        /*
        1、能被4整除且不能被100整除的是闰年
        2、能被400整除的是闰年
         */
        if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){
            System.out.println(year+"是闰年");
            return true;
        }else{
            System.out.println(year+"不是闰年");
            return false;
        }

    }
    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入年份：");
        int year = scan.nextInt();
        //方法的调用
        isLeapYear(year);

    }

    //求阶乘
    //方法1
    public static  int fac(int n){
        if(n == 1 || n == 0){
            return 1;
        }else {
            return n * fac(n - 1);
        }
    }
    //方法2
    public  static int fac2(int n){
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        return ret;
    }
    public static void main3(String[] args) {
        //计算 1! + 2! + 3! + 4! + 5!
        int sum = 0;
        for (int i = 1; i <= 5 ; i++) {
            sum += fac(i);
        }
        System.out.println(sum);

    }
    //交换两个数值
    public static void swap(int x, int y){
        int tmp =x;
        x = y;
        y = tmp;
    }

    public static void main4(String[] args) {
        int a = 10,b = 20;
        System.out.println("交换前："+a+" "+b);
        swap(a,b);
        System.out.println("交换后："+a+" "+b);
    }
}
